package com.xyzq.cgate.common.constant;

import com.google.common.base.Joiner;
import org.springframework.http.ResponseEntity;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;

import static io.netty.handler.codec.http.HttpHeaderValues.CHARSET;


/**
 * @Description:
 * @author chenchen
 * @date 2019/6/14 13:36
 */
public class ZkPathConstants {

    public static final String PLUGIN_PARENT_PATH = "/cgate/plugin";

    public static final String RULE_PARENT_PATH = "/cgate/rule";

    public static final String SIGN_PARENT_PATH = "/cgate/sign";

    public static String buildPluginZkPath(String pluginName) {
        return Joiner.on("/").skipNulls().join(PLUGIN_PARENT_PATH, pluginName);
    }

    public static String buildRuleZkPath(final String pluginName) {
        return Joiner.on("/").skipNulls().join(RULE_PARENT_PATH, pluginName);

    }

    public static String buildBottomRuleZkPath(final String pluginName, final String ruleName) throws UnsupportedEncodingException {
        return Joiner.on("/").skipNulls().join(RULE_PARENT_PATH, pluginName, URLEncoder.encode(ruleName, StandardCharsets.UTF_8.name()));
    }

    public static String buildBottomRuleZkPathWithoutEncode(final String pluginName, final String ruleName) {
        return Joiner.on("/").skipNulls().join(RULE_PARENT_PATH, pluginName, ruleName);
    }



}
